package com.qfedu.user.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qfedu.common.annotation.NoLoginCheck;
import com.qfedu.common.utils.R;
import com.qfedu.user.param.UserVO;
import com.qfedu.user.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 2025/1/14下午7:29
 */
@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

    @NoLoginCheck
    @GetMapping("/list")
    public R findAll(UserVO userVO) {

        PageHelper.startPage(userVO.getPageNum(), userVO.getPageSize());
        List<UserVO> list = userService.findAll(userVO);
        log.info("分页查询结果:{}", list);
        PageInfo<UserVO> pageInfo = new PageInfo<>(list);
        return R.ok(pageInfo);
    }
}
